/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package visualization;

import gov.nasa.worldwind.geom.Angle;
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.geom.Position.PositionList;
import gov.nasa.worldwind.render.Polygon;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Dark Mark
 */
public class Ship extends Polygon
{
    private Position position;
    public float width;
    public float height;
    public float altitude;

    public Ship()
    {
        super();
    }

    public Ship(float width, float height, float altitude)
    {
        this();

        ArrayList<Position> shipBorders = new ArrayList<Position>();
        shipBorders.add(Position.fromDegrees(0, 0, 10e4));
        shipBorders.add(Position.fromDegrees(0, height, 10e4));
        shipBorders.add(Position.fromDegrees(width, height, 10e4));
        shipBorders.add(Position.fromDegrees(width, 0, 10e4));

        this.setOuterBoundary(shipBorders);

        this.width = width;
        this.height = height;
        this.altitude = altitude;
    }

    @Override
    public void moveTo(Position pstn)
    {
        pstn = Position.fromRadians(pstn.getLatitude().getRadians()-0.000001, pstn.getLongitude().getRadians()+0.0000065, pstn.getAltitude());
        super.moveTo(pstn);

        ArrayList<Position> borders = (ArrayList<Position>) getOuterBoundary();
        double lat = (borders.get(0).getLatitude().getRadians()+borders.get(2).getLatitude().getRadians())/2;
        double lon = (borders.get(0).getLongitude().getRadians()+borders.get(2).getLongitude().getRadians())/2;
        position = Position.fromRadians(lat, lon, altitude);
        borders = null;
    }

    public Position getPosition()
    {
        return position;
    }
    
}
